package com.qf.java2201.web;

import com.qf.java2201.dao.UserinfoDao;
import com.qf.java2201.dao.impl.UserinfoDaoImpl;
import com.qf.java2201.pojo.HComment;
import com.qf.java2201.pojo.HUserinfo;
import com.qf.java2201.service.CommentService;
import com.qf.java2201.service.UserinfoService;
import com.qf.java2201.service.impl.CommentServiceImpl;
import com.qf.java2201.service.impl.UserinfoServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/showXq")
public class ShowXqServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String did = req.getParameter("did");

        UserinfoService userinfoService = new UserinfoServiceImpl();

        HUserinfo uis =userinfoService.findUserinfoByKdid(did);

       // req.setAttribute("doc",uis);
        HttpSession session = req.getSession();
        session.setAttribute("doc",uis);

        CommentService commentService = new CommentServiceImpl();

        List<HComment> comment = commentService.findCommentById(did);
        req.setAttribute("cs", comment);

        req.getRequestDispatcher("/xq.jsp").forward(req,resp);

    }
}
